package com.ygxsk.carhome.ui.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.PropertyRepairTransBean;

import java.util.List;

public class PropertyRepairTransAdapter extends BaseQuickAdapter<PropertyRepairTransBean, BaseViewHolder> {
    public PropertyRepairTransAdapter(int layoutResId, @Nullable List<PropertyRepairTransBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, PropertyRepairTransBean item) {

        if (item != null) {

            //填充布局内容
            String imgUrl = item.getImgUrl();

            String typeName = item.getTypeName();

            //测试的时候放开
            //String twoStairRepairTypeName = "包含空调电视机挂壁炉中包含空调电" +
            //"视机挂壁炉中央空电视机挂壁炉中央空电视机挂壁炉中央空电视机挂壁炉中央空调柜子桌椅窗帘央空调柜子桌椅窗帘";
            String twoStairRepairTypeName = item.getTwoStairRepairTypeName();


            //左侧的图片内容
            //ImageView imageviewintrans = (ImageView) helper.getView(R.id.imageviewintransin);


            //加载左侧商品图片内容
            Glide.with(getContext())//
                    .load(imgUrl.trim())//
                    //.transition(withCrossFade())
                    .placeholder(R.drawable.icon_errorfang)//
                    .fallback(R.drawable.icon_errorfang)//
                    .error(R.drawable.icon_errorfang)//
                    .into((ImageView) baseViewHolder.getView(R.id.imageviewintransin));//


            baseViewHolder.setText(R.id.texttypename, TextUtils.isEmpty(typeName) ? "" : typeName);
            baseViewHolder.setText(R.id.texttwostairrepairtypename, TextUtils.isEmpty(twoStairRepairTypeName) ? "" : twoStairRepairTypeName);

            //点击事件不放在这里，直接放在列表条目之中

        }
    }
}
